<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'da.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8">

<link rel="stylesheet" href="js/easyui/demo/demo.css" type="text/css"></link>
<link rel="stylesheet" href="js/easyui/themes/icon.css" type="text/css"></link>
<link rel="stylesheet" href="js/easyui/themes/default/easyui.css"
	type="text/css"></link>
<script type="text/javascript" src="js/easyui/jquery-1.6.min.js"></script>
<script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="script/common.js"></script>
<script type="text/javascript" src="js/easyui/themes/easyui-lang-zh_CN.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
.form-table tr td:first-child {
	width: 5.5em;
	text-align: right;
}
</style>
<script type="text/javascript">
	/**
	 * 根据制定页面跳转
	 */
	function reload() {
		var offset = document.getElementById("offset").value;
		var idx = (offset == null) ? 0 : parseInt(offset) - 1;
			
		window.location = 'procurepgetAllProcurep?offset=' + idx;
	}
	
	/**
	 * 根据条件查询
	 */
	function query() {
		var qproductCode = $("#productCode").val();
		var qsendTime = $("#qsendTime").val();
		var qendTime = $("#qendTime").val();
		var qstatus = $("#status").combobox("getValue");
		
		window.location = 'pinquirysuinInquiryList?qproductCode='+qproductCode
				+'&qsendTime='+qsendTime+'&qendTime='+qendTime+'&qstatus='+qstatus;
		
	}
	
	/**
	* 翻到给定偏移量的页面
	*/
	function turnPage(offset){
		var qproductCode = $("#productCode").val();
		var qsendTime = $("#qsendTime").val();
		var qendTime = $("#qendTime").val();
		var qstatus = $("#status").combobox("getValue");
		
		window.location = 'pinquirysuinInquiryList?qproductCode='+qproductCode
				+'&qsendTime='+qsendTime+'&qendTime='+qendTime+'&qstatus='+qstatus+'&offset=' + offset;	
				
	}
	
	/**
	 * 状态格式化
	 */
	 function statusFormater(val,row){
	 	val = val.trim();
		switch(val){
			case '0':
				val = "草稿";
			break;
			case '1':
				val= "询价中";
			break;
			case '2':
				val= "已报价";
			break;
			case '3':
				val= "生产中";
			break;
			case '4':
				val= "已完成";
			break;
			case '5':
				val= "已关闭";
			break;
		}
		return val;
	}
	
	/**
	 * 格式化报价链接
	 */
	function formaterSuppQuote(value,row,index){
		var productCode = row['productCode'].trim();
		var rowInfo = JSON.stringify(row);
		
		//$("#wproductCode").textbox('setValue',productCode);//赋值
		//var openWin = "$('#suppQuoteWin').window('open')";
		//$('#suppQuoteWin').panel({title:'产品报价'});
		var linkPage = "addPanelExists('supplierQuote.jsp','供应商询价报价')";
		value = "<a onclick='procureInquiry("+rowInfo+")'; style='text-decoration: underline;'>报价</a>";
		return value;
	}
	
	function procureInquiry(rowInfo){
		var quoteInfo = "";
		
		var pqId = rowInfo.pqId.trim();
		var productCode = rowInfo.productCode.trim();
		var blueprint = rowInfo.blueprint;
		if(blueprint==undefined){
			blueprint = "";
		}else{
			blueprint = blueprint.trim();
			$("#disDiv").html(blueprint);
			blueprint = $("#photoShow").attr('src');
		}
		var procCount = rowInfo.procCount.trim();
		var sysUser = rowInfo.sysUser.trim();
		var suid = rowInfo.suid.trim();
		var sendTime = rowInfo.sendTime.trim();
		sendTime = $(sendTime).text();
		var endTime = rowInfo.endTime.trim();
		endTime = $(endTime).text();
		var deliveryDate = rowInfo.deliveryDate.trim();
		deliveryDate = $(deliveryDate).text();
		
		quoteInfo = "{'pqId':"+pqId+",'productCode':'"+productCode+"','blueprint':'"+blueprint+"',"+
		"'procCount':"+procCount+",'sysUser':'"+sysUser+"','suid':'"+suid+"',"+
		"'sendTime':'"+sendTime+"','endTime':'"+endTime+"','deliveryDate':'"+deliveryDate+"'}";
		
		var url = "pinquirygetQuoteInfo.action?quoteInfo="+quoteInfo;
		addPanelExists(url,'供应商询价报价');

		
	}
	
</script>
</head>

<body>
	<div style="display: none;">
		<div id="suppQuoteWin" class="easyui-window" collapsible="false" minimizable="false" title="产品报价"
			maximizable="false" closed="true"  modal="true" style="width:350px;"> 
			 <table  class="form-table">
			 	<tr>
			 		<td>产品编码：</td>
			 		<td>
			 			<input class="easyui-textbox" disabled="disabled" id="wproductCode" prompt="产品款号" value="" data-options="height:26">
			 		</td>
			 	</tr>
			 	
			 	<tr>
			 		<td>报价：</td>
			 		<td>
			 			<input class="easyui-textbox" id="wprice" prompt="报价" value="" data-options="height:26">
			 		</td>
			 	</tr>
			 </table>
			 <div style="display:none;">
			 	<input class="easyui-textbox" id="winfo" value="">
			 </div>
			 <div style="text-align: center; margin-top: -10px;margin-bottom: 10px;">
				<a onclick="suppQuote()" class="easyui-linkbutton" style="margin-left: 10px;padding: 0px 3px;">保存</a>
			 </div>
		</div>  
	</div>
	<div style="margin:20px 20px 0px 20px; width:85%;">
		<div id="options" class="toolbar">
			<div style="width: 100%;float: none;">
				<div style="float: left;">
					<a onclick="" class="easyui-linkbutton"
						data-options="iconCls:'icon-add'" style="margin-right: 10px;">新增</a>
					<a href="procurepgetAllProcurep" class="easyui-linkbutton"
						data-options="iconCls:'icon-reload'" style="margin-right: 10px;">刷新</a>
				</div>
				<div style="float: left; margin-bottom: 10px;">
					<input class="easyui-textbox" type="text" id="qproductCode" prompt="产品款号" value="${qproductCode}" data-options="height:26">
					<input class="easyui-datebox" type="text" id="qsendTime" prompt="开始时间" value="${qsendTime}" data-options="height:26">
					<span>-</span>
					<input class="easyui-datebox" type="text" id="qendTime" prompt="结束时间" value="${qendTime}" data-options="height:26">
					<select id="status" class="easyui-combobox" style="width:148px;height:26px" prompt="状态" panelHeight="110"; editable="false">
						<option value=""></option>
						<option value="0" <c:if test="${status==0}"> selected="true"</c:if>>草稿</option>
						<option value="1" <c:if test="${status==1}"> selected="true"</c:if>>询价中</option>
						<option value="2" <c:if test="${status==2}"> selected="true"</c:if>>已报价</option>
						<option value="3" <c:if test="${status==3}"> selected="true"</c:if>>生产中</option>
						<option value="4" <c:if test="${status==4}"> selected="true"</c:if>>已完成</option>
						<option value="5" <c:if test="${status==5}"> selected="true"</c:if>>已关闭</option>
					</select>
				</div>
				<div style=" float: left;">
					<input class="easyui-linkbutton"
						type="button" id="query" style="margin-left: 15px;"
						onclick="query()" value="查询 ">
				</div>
			</div>
		</div>
		<div style="width:100%; float: left;" id = "show">
			<table class="easyui-datagrid" style="width:70%;" singleSelect="true" id="procureInquiryGird">
				<thead>
					<tr>
						<th data-options="field:'code'">序号</th>
						<th data-options="field:'productCode'">产品款号</th>
						<th data-options="field:'blueprint'">设计图</th>
						<th data-options="field:'procCount'">采购数量</th>
						<th data-options="field:'sysUser'">发布人员</th>
						<th data-options="field:'sendTime'">开始时间</th>
						<th data-options="field:'endTime'">结束时间</th>
						<th data-options="field:'deliveryDate'">交货时间</th>
						<th data-options="field:'status'" formatter="statusFormater">状态</th>
						<th data-options="field:'操作'" formatter="formaterSuppQuote">操作</th>
						<th data-options="field:'pqId',hidden:true">询价单ID</th>
						<th data-options="field:'suid',hidden:true">供应商ID</th>
					</tr>
				</thead>
				
				<c:choose>
					<c:when test="">
						<tr style="text-align: center;">
							<td colspan="11">
								<span style="color: grey;"></span>
							</td>
						</tr>
					</c:when>
					<c:otherwise>
						<c:forEach items="${suinInquiryList}" var="inquiry" varStatus="i">
							<tr>
								
								<td>
									<c:out value="${i.index+1+offset*10 }" />
								</td>
								
								<td>
									<c:out value="${inquiry.procureProduct.productCode}" />
								</td>
								
								<td>
									<img alt="" id="photoShow" src="${inquiry.procureProduct.blueprint}">
								</td>
								
								<td>
									<c:out value="${inquiry.procureProduct.procCount}" />
								</td>
								
								<td>
									<c:out value="${inquiry.procureProduct.sysUser}" />
								</td>
								
								<td>
									<fmt:setLocale value="zh_cn" /> 
									<a title="${inquiry.sendTime}"><font><fmt:formatDate value="${inquiry.sendTime}" type="date" dateStyle="long" /></font></a>
								</td>
								
								<td>
									<fmt:setLocale value="zh_cn" /> 
									<a title="${inquiry.endTime}"><font><fmt:formatDate value="${inquiry.endTime}" type="date" dateStyle="long" /></font></a>
								</td>
								
								<td>
									<fmt:setLocale value="zh_cn" /> 
									<a title="${inquiry.procureProduct.deliveryDate}"><font><fmt:formatDate value="${inquiry.procureProduct.deliveryDate}" type="date" dateStyle="long" /></font></a>
								</td>
								
								<td>
									<c:out value="${inquiry.procureProduct.status}"></c:out>
								</td>
								<td>
									
								</td>
								<td>
									<c:out value="${inquiry.pqId}"></c:out>
								</td>
								<td>
									<c:out value="${inquiry.suid}"></c:out>
								</td>
							</tr>
						</c:forEach>
					</c:otherwise>
				</c:choose>
			</table>
			<div id="disDiv" style="display: none"></div>
			<div class="pager" id="pagebar">
				共<b id="ttCount">${totalcount }</b>条记录 转到&nbsp;<input value="${offset+1}" size="2" id="offset" class="easyui-textbox" />&nbsp;页/<b id="ttPage">${totalpage }</b>页
				<button class="easyui-linkbutton jump-btn" width="20" onclick="reload()">跳转</button>
				<a onclick="turnPage(0)">&lt;&lt; 第一页</a> <a
					onclick="turnPage(${offset-1})">&lt; 上一页</a> <a
					onclick="turnPage(${offset+1})">下一页 &gt;</a> <a
					onclick="turnPage(${totalpage-1})">最后一页 &gt;&gt;</a>
			</div>
		</div>
	</div>

</body>
</html>
